<!--

    Copyright © 2016-2019 The Thingsboard Authors

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<div class="trip-animation-widget" layout="column" layout-align="center start"
     ng-style="{'padding-top' : (!vm.widgetConfig.showTitle && vm.ctx.settings.showLabel) ? '5px' : '0px'}">
    <div class="trip-animation-label-container" ng-show="vm.ctx.settings.showLabel">
        {{vm.trips[vm.activeTripIndex].settings.labelText}}
    </div>
    <div class="trip-animation-container" layout="column">
        <div flex id='trip-animation-map'></div>
        <div class="trip-animation-info-panel" layout="row">
            <md-button class="md-primary md-fab" aria-label="tooltip" ng-show="vm.staticSettings.displayTooltip" ng-click="vm.showHideTooltip()">
                <ng-md-icon icon="info_outline"></ng-md-icon>
            </md-button>
        </div>
        <div class="trip-animation-tooltip md-whiteframe-z4" layout="column" ng-class="!vm.staticSettings.showTooltip ? 'trip-animation-tooltip-hidden':''" ng-bind-html="vm.mainTooltip"
        ng-style="{'background-color': vm.staticSettings.tooltipColor, 'opacity': vm.staticSettings.tooltipOpacity, 'color': vm.staticSettings.tooltipFontColor}">
        </div>
    </div>
    <div class="trip-animation-control-panel">
        <md-slider-container>
            <md-button class="md-icon-button" aria-label="Start" ng-click="vm.moveStart()">
                <md-icon class="material-icons" ng-style="{'color': vm.staticSettings.buttonColor}">fast_rewind</md-icon>
            </md-button>
            <md-button class="md-icon-button" aria-label="Previous" ng-click="vm.movePrev()">
                <md-icon class="material-icons" ng-style="{'color': vm.staticSettings.buttonColor}">skip_previous</md-icon>
            </md-button>
            <md-slider ng-model="vm.index" min="{{vm.minTime}}" max="{{vm.maxTime}}" ng-change="vm.recalculateTrips()"></md-slider>
            <md-button class="md-icon-button" aria-label="Next" ng-click="vm.moveNext()">
                <md-icon class="material-icons" ng-style="{'color': vm.staticSettings.buttonColor}">skip_next</md-icon>
            </md-button>
            <md-button class="md-icon-button" aria-label="End" ng-click="vm.moveEnd()">
                <md-icon class="material-icons" ng-style="{'color': vm.staticSettings.buttonColor}">fast_forward</md-icon>
            </md-button>
            <md-button class="md-icon-button" aria-label="Play" ng-click="vm.playMove(true)" ng-disabled="vm.isPlaying">
                <md-icon class="material-icons" ng-style="{'color': vm.isPlaying ? vm.staticSettings.disabledButtonColor : vm.staticSettings.buttonColor}">
                    play_circle_outline
                </md-icon>
            </md-button>
            <md-select ng-model="vm.speed" aria-label="Speed selector">
                <md-option ng-value="speed" flex="1" ng-repeat="speed in vm.speeds track by $index">{{ speed}}
                </md-option>
            </md-select>
            <md-button class="md-icon-button" aria-label="Stop playing" ng-click="vm.stopPlay()" ng-disabled="!vm.isPlaying">
                <md-icon class="material-icons" ng-style="{'color': vm.isPlaying ? vm.staticSettings.buttonColor : vm.staticSettings.disabledButtonColor}">
                    pause_circle_outline
                </md-icon>
            </md-button>
        </md-slider-container>
        <div class="panel-timer">{{vm.trips[vm.activeTripIndex].timeRange[vm.index].ts | date:'medium'}}
        </div>
    </div>
</div>
